#!/bin/bash

# 安装依赖
sudo npm i -d --registry=https://registry.npm.taobao.org

# 获取ZOOKEEPER地址

zookeeperArray=($(echo $ZOOKEEPER_ADDR | sed  's/,/ /g'))
zookeeperAddr="";
for var in ${zookeeperArray[@]}
do
  if [ -n "$zookeeperAddr" ] ; then
   zookeeperAddr=$zookeeperAddr','
  fi
  zookeeperAddr=$zookeeperAddr'"'$var'"'
done

zookeeperAddr=($(echo $zookeeperAddr | sed 's/[[:space:]]//g'))

sudo sed -i "s/\${SERVER_IP}/$SERVER_IP/g" /project/smartstack/nerve/nerve_services/seckillRedisService.json
sudo sed -i "s/\${ZOOKEEPER_ADDR}/$zookeeperAddr/g" /project/smartstack/nerve/nerve_services/seckillRedisService.json
#sudo sed -i "s/\${ZOOKEEPER_ADDR}/$zookeeperAddr/g" /project/smartstack/synapse/synapse_services/orderhandle.json

# 配置smartstack

nohup /bin/bash -l -c 'nerve -c /project/smartstack/nerve/nerve.conf.json' &
#nohup /bin/bash -l -c 'synapse -c /project/smartstack/synapse/synapse.conf.json' &


# 开发情况以开发模式启动,生产模式调整为npm start
npm run start
